package office.action.hr;

import java.util.List;
import office.action.hr.form.RecruitRequirementForm;
import office.service.hr.IRecruitRequirementService;
import platform.common.action.BaseAction;

/**
 * 招聘需求Action
 */
public class RecruitRequirementAction extends BaseAction{
	
	private static final long serialVersionUID = 1L;
	private IRecruitRequirementService recruitRequirementService;
	private RecruitRequirementForm objctForm;
	private String id;
	@SuppressWarnings("unchecked")
	private List wrapperList;
	
	public String recruitRequirementList()throws Exception{
		//TODO 获取用户所属部门
		String deptId = getUserDepartmentId();
		String roleName = getUserRoleName();
		boolean flag = false;
		if(roleName.equals("zjl") || roleName.equals("xzrsjl") || roleName.equals("xzzl") || roleName.equals("rszl")){
			flag = true;
		}
		wrapperList = recruitRequirementService.getRecruitRequirementList(deptId,flag);
		return "showList";
	}
	/**
	 * 跳转到编辑页面
	 * @return
	 * @throws Exception
	 */
	public String gotoAdd()throws Exception{
		return "gotoEdit";
	}
	/**
	 * 跳转到编辑页面
	 * @return
	 * @throws Exception
	 */
	public String gotoEdit()throws Exception{
		objctForm = recruitRequirementService.getById(id);
		System.out.println(objctForm.getId());
		return "gotoEdit";
	}
	/**
	 * 添加或编辑数据
	 * @return
	 * @throws Exception
	 */
	public String editData() throws Exception{
		try {
			objctForm.setDeptId(getUserDepartmentId());
			recruitRequirementService.editRecruitRequirement(objctForm);
			if(null==objctForm.getId() || ("").equals(objctForm.getId())){
				this.getAjaxMessagesJson().setMessage(true, "", "新建成功");
			}else{
				this.getAjaxMessagesJson().setMessage(true, "", "编辑成功");
			}
		} catch (Exception e) {
			this.handleException(e);
		}
		return RESULT_AJAXJSON;
	}
	/**
	 * 初始化可用操作
	 * @return
	 * @throws Exception
	 */
	public String gotoEditXml()throws Exception{
		return "editXml";
	}
	/**
	 * 初始化删除
	 * @return
	 * @throws Exception
	 */
	public String gotoDel()throws Exception{
		return "gotoDel";
	}
	/**
	 * 删除
	 * @return
	 * @throws Exception
	 */
	public String delData()throws Exception{
		try {
			recruitRequirementService.deleteById(id);
			this.getAjaxMessagesJson().setMessage(true, "", "删除成功");
			
		} catch (Exception e) {
			this.handleException(e);
		}
		return RESULT_AJAXJSON;
	}

	public IRecruitRequirementService getRecruitRequirementService() {
		return recruitRequirementService;
	}
	public void setRecruitRequirementService(
			IRecruitRequirementService recruitRequirementService) {
		this.recruitRequirementService = recruitRequirementService;
	}
	@SuppressWarnings("unchecked")
	public List getWrapperList() {
		return wrapperList;
	}
	@SuppressWarnings("unchecked")
	public void setWrapperList(List wrapperList) {
		this.wrapperList = wrapperList;
	}
	public RecruitRequirementForm getObjctForm() {
		return objctForm;
	}
	public void setObjctForm(RecruitRequirementForm objctForm) {
		this.objctForm = objctForm;
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	
	

	
	
}
